package yanyan.com.tochar.thread;

import yanyan.com.tochar.beans.ToChanrBean;
import yanyan.com.tochar.beans.VideoThreadInfo;
import yanyan.com.tochar.utils.PictureSelectUtil;
import yanyan.com.tochar.utils.ToCharUtil;

public class VideoThreadTask implements Runnable{

    private VideoThreadInfo info;

    public VideoThreadTask(VideoThreadInfo info) {
        this.info = info;
    }
    public VideoThreadTask() {

    }

    @Override
    public void run() {
        ToChanrBean toChanrBean=null;
        if(info.isCN()){
            if(info.isColor()){
                toChanrBean= ToCharUtil.createAsciiPicColorCN(info.getBitmap(),info.getTxt(), info.getContext());
            }else {
                toChanrBean=ToCharUtil.createAsciiPicCN(info.getBitmap(),info.getTxt()
                        ,info.getContext());
            }
        }else {
            if(info.isColor()){
                toChanrBean= ToCharUtil.createAsciiPicColor(info.getBitmap(),info.getTxt(), info.getContext());
            }else {
                toChanrBean=ToCharUtil.createAsciiPic(info.getBitmap(),info.getTxt(),info.getContext());
            }
        }

        //将图片缓存到本地
        String s = PictureSelectUtil.cacheBitmap(toChanrBean.getBitmap(), info.getFileName(), info.getContext(),100);
        //将字符保存到列表
        //将路径储存到map里
        VideoThreadInfo.setIndex(s,toChanrBean.getText());
    }
}
